﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Datorgrafik_lab2.Objects {
    class Axes {
        private VertexPositionColor[] vertices;
        private VertexBuffer vb;
        GraphicsDevice graphicsDevice;

        public Axes(GraphicsDevice graphicsDevice) {
            this.graphicsDevice = graphicsDevice;
            initAxes();
            vb = new VertexBuffer(graphicsDevice, typeof(VertexPositionColor), vertices.Length, BufferUsage.WriteOnly);
            vb.SetData(vertices);
        }

        public void draw() {
            graphicsDevice.SetVertexBuffer(vb);
            graphicsDevice.DrawPrimitives(PrimitiveType.LineList, 0, vertices.Length / 2);
        }

        private void initAxes() {
            float size = 100f;
            vertices = new VertexPositionColor[6];
            vertices[0] = new VertexPositionColor(new Vector3(size, 0f, 0f), Color.Green); //X Max =10
            //vertices[1] = new VertexPositionColor(new Vector3(-size, 0f, 0f), Color.Green); //X Min =-10
            vertices[1] = new VertexPositionColor(new Vector3(0, 0f, 0f), Color.Green); //X Min =-10
            vertices[2] = new VertexPositionColor(new Vector3(0f, size, 0f), Color.Red); //Y Max =10
            //vertices[3] = new VertexPositionColor(new Vector3(0f, -size, 0f), Color.Red); //Y Min =-10
            vertices[3] = new VertexPositionColor(new Vector3(0f, -0, 0f), Color.Red); //Y Min =-10
            vertices[4] = new VertexPositionColor(new Vector3(0f, 0f, size), Color.Blue); //Z Max =10
            //vertices[5] = new VertexPositionColor(new Vector3(0f, 0f, -size), Color.Blue); //Z Min =-10
            vertices[5] = new VertexPositionColor(new Vector3(0f, 0f, -0), Color.Blue); //Z Min =-10
        }
    }
}

